<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Login Page</title>
    <link rel="shortcut icon" href="../ff.ico" type="image/x-icon">
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="../Pear-Admin-Layui/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="../Pear-Admin-Layui/admin/css/other/login.css"/>
</head>
<!-- 代 码 结 构 -->
<body background="../Pear-Admin-Layui/admin/images/background2.svg" style="background-size: cover;">
<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <img class="logo" src="../Pear-Admin-Layui/admin/images/logo.png"/>
        <div class="title">个人管理系统</div>
        <div class="desc">

        </div>
    </div>
    <div class="layui-form-item">
        <input placeholder="账 户 : admin " name="name" type="text" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input placeholder="密 码 : admin " name="password" type="password" hover class="layui-input"/>
    </div>

    <div class="layui-form-item">
<!--        <div class="pear-btn pear-btn-success pwd" style="display: inline-block;width: 100%;font-size: 16px;font-weight: bold;height: 44px;line-height: 41px">-->
<!--            获取密码-->
<!--        </div>-->
        <button type="button" class="pear-btn pear-btn-success login"
                style="background-color: #ff3451 !important;margin-top: 5px"
                lay-submit lay-filter="login">
            登 录
        </button>
    </div>
</form>
<!-- 资 源 引 入 -->
<script src="../Pear-Admin-Layui/component/layui/layui.js"></script>
<script src="../Pear-Admin-Layui/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'element', 'jquery', 'button', 'popup', 'notice'], function () {
        var form = layui.form;
        var element = layui.element;
        var button = layui.button;
        var popup = layui.popup;
        var notice = layui.notice;
        var $ = layui.jquery;

        // 获取密码
        // $(".pwd").on('click', function () {
        //     $.ajax({
        //         url: '/user/getPassword',
        //         type: 'get',
        //         dataType: 'json',
        //         success: function (res) {
        //             layer.msg(res.msg, {
        //                 offset: '15px'
        //                 , skin: 'demo-class'
        //                 , icon: 1
        //                 , time: 500
        //             });
        //         }
        //     })
        // })

        // 登录提交
        form.on('submit(login)', function (data) {
            $.ajax({
                url: '/user/login',
                type: 'post',
                data: {userName: $("input[name='name']").val(), password: $("input[name='password']").val()},
                dataType: 'json',
                success: function (res) {
                    if (res.code == 0) {
                        $("input[name='name']").val('');
                        $("input[name='password']").val('');
                        //登入成功的提示与跳转
                        layer.msg('登陆成功', {
                            offset: '15px'
                            , skin: 'demo-class'
                            , icon: 1
                            , time: 500
                        }, function () {

                            location.href = '/index'; //后台主页
                        });
                    } else {
                        layer.msg(res.msg, {
                            offset: '15px'
                            , icon: 0
                            , time: 700
                        })
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>
